<template>
    <div>

        <label for="nickName">账号：<input v-model="nickName" name="nickName" type="text"></label>
        <br>
        <button @click="login">登陆</button>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                nickName: ""
            }
        },
        methods: {
            login() {
                window.lfdChart = new WebSocket(`ws://10.46.54.205:8081/sp-demo//socket/login/${this.nickName}`)
                window.lfdChart.onmessage = (data) => {

                    if (data.data.includes("上线了")) {
                        window.nickName = this.nickName
                        this.$router.push({
                            name: "zlt"
                        })
                    }
                }
            }
        }

    }
</script>

<style>

</style>